home *** CD-ROM | disk | FTP | other *** search
/ Mastering Computers 3 / Mastering Computers Vol 3.iso / Win95 / Fun&Utils / MFCMSG.EXE / VIEW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-01  |  1.5 KB  |  64 lines

  1. #include "stdafx.h"
  2. #include "cmdlearn.h"
  3. #include "doc.h"
  4. #include "view.h"
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <mmsystem.h>
  8.  
  9. IMPLEMENT_DYNCREATE(CFileView, CView)
  10.  
  11. BEGIN_MESSAGE_MAP(CFileView, CView)
  12.    //{{AFX_MSG_MAP(CFileView)
  13.    //}}AFX_MSG_MAP
  14. END_MESSAGE_MAP()
  15.  
  16. CFileView::CFileView()
  17. {
  18. }
  19.  
  20. CFileView::~CFileView()
  21. {
  22. }
  23.  
  24. /////////////////
  25. // Update this view. If the hint is that the document was deleted,
  26. // close the window and play a little cork pop sound.
  27. //
  28. void CFileView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
  29. {
  30.    if (lHint==ID_FILE_CLOSE) {
  31.       PostMessage(WM_COMMAND, ID_FILE_CLOSE);
  32.       PlaySound(MAKEINTRESOURCE(IDR_FILEINTYPE), 
  33.          AfxGetInstanceHandle(), SND_RESOURCE | SND_NODEFAULT | SND_NOWAIT);
  34.       return;
  35.    }
  36.    TView::OnUpdate(pSender, lHint, pHint);
  37. }
  38.  
  39. //////////////////
  40. // Display file informationin in window.
  41. //
  42. void CFileView::OnDraw(CDC* pDC)
  43. {
  44.    CFileDoc* pDoc = GetDocument();
  45.    ASSERT_VALID(pDoc);
  46.  
  47.    const CFileStatus& status = pDoc->m_status;
  48.    char strbuf[1024];
  49.    sprintf(strbuf,"File:\t%s\nSize:\t%ld",
  50.       (const char*)pDoc->GetPathName(),
  51.       status.m_size);
  52.  
  53.    // Build text string, then draw it
  54.    CString msg = strbuf;
  55.    msg += status.m_ctime.Format("\nCreated:\t%m-%d-%y %I:%M %p");
  56.    msg += status.m_atime.Format("\nAccess:\t%m-%d-%y %I:%M %p");
  57.    msg += status.m_mtime.Format("\nMod:\t%m-%d-%y %I:%M %p");
  58.  
  59.    CRect rc;
  60.    GetClientRect(&rc);
  61.    pDC->DrawText(msg, msg.GetLength(), rc, DT_EXPANDTABS);
  62. }
  63.  
  64.